// 封装关于购物车操作的接口

import axios from "@/utils/http";

// 添加购物车的接口
export const addCartAPI = (data) => {
    return axios({
        url: "/addCart",
        method: "post",
        data,
    });
};

// 修改购物车的数量接口
export const updatedCartAPI = (data) => {
    return axios({
        url: "/updateCart",
        method: "put",
        data,
    });
};

// 购物车中修改菜品数量的接口
export const updateCartByIdAPI = (data) => {
    return axios({
        url: "/updateCartById",
        method: "put",
        data,
    });
};

// 获取登录用户的购物车数据接口
export const getCartDataAPI = (params) => {
    return axios({
        url: "/getCartData",
        method: "get",
        params,
    });
};

// 批量删除购物车中选中的菜品接口
export const deleteCartByIdsAPI = (ids) => {
    return axios({
        url: "/deleteCartByIds",
        method: "get",
        params: {
            ids: ids.join(","), // 使用逗号或其他分隔符将数组元素连接成字符串
        },
    });
};